
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module main</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>main</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jumer/Documents/CS373/cs373p1/main.py">/home/jumer/Documents/CS373/cs373p1/main.py</a></font></td></tr></table>
    <p><tt>#&nbsp;-------------------------------<br>
#&nbsp;projects/python/collatz/main.py<br>
#&nbsp;Copyright&nbsp;(C)&nbsp;2009<br>
#&nbsp;Glenn&nbsp;P.&nbsp;Downing<br>
#&nbsp;-------------------------------</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="types.html">types</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="main.html#InputReader">InputReader</a>
</font></dt><dt><font face="helvetica, arial"><a href="main.html#OutputWriter">OutputWriter</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="InputReader">class <strong>InputReader</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="InputReader-read"><strong>read</strong></a>(self)</dt></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="OutputWriter">class <strong>OutputWriter</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="OutputWriter-write"><strong>write</strong></a>(self, *a)</dt></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-cycle_length"><strong>cycle_length</strong></a>(n)</dt><dd><tt>recursively&nbsp;calculates&nbsp;the&nbsp;cycle&nbsp;length&nbsp;of&nbsp;n&nbsp;for&nbsp;the&nbsp;3n&nbsp;+&nbsp;1&nbsp;problem.<br>
this&nbsp;function&nbsp;uses&nbsp;and&nbsp;adds&nbsp;to&nbsp;the&nbsp;global&nbsp;cache.<br>
&nbsp;<br>
cycle&nbsp;length&nbsp;of&nbsp;1&nbsp;is&nbsp;defined&nbsp;as&nbsp;1&nbsp;(per&nbsp;UVA)<br>
&nbsp;<br>
n&nbsp;is&nbsp;even&nbsp;=&gt;&nbsp;cycle_length&nbsp;(n)&nbsp;=&nbsp;1&nbsp;+&nbsp;<a href="#-cycle_length">cycle_length</a>(n&nbsp;/&nbsp;2)<br>
n&nbsp;is&nbsp;odd&nbsp;=&gt;&nbsp;cycle_length&nbsp;(n)&nbsp;=&nbsp;2&nbsp;+&nbsp;<a href="#-cycle_length">cycle_length</a>(&nbsp;n&nbsp;+&nbsp;(n&nbsp;&gt;&gt;&nbsp;1)&nbsp;+&nbsp;1&nbsp;)<br>
&nbsp;&nbsp;&nbsp;&nbsp;nb:&nbsp;this&nbsp;is&nbsp;a&nbsp;shortcut&nbsp;for&nbsp;speed&nbsp;optimization.&nbsp;if&nbsp;we&nbsp;have&nbsp;odd&nbsp;n&nbsp;that&nbsp;isn't&nbsp;one,&nbsp;we'll&nbsp;multiply&nbsp;by&nbsp;3n+1,&nbsp;which&nbsp;yields&nbsp;an&nbsp;even,&nbsp;then&nbsp;divide&nbsp;by&nbsp;2.<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
@param&nbsp;n&nbsp;the&nbsp;number&nbsp;to&nbsp;find&nbsp;the&nbsp;cycle&nbsp;length&nbsp;for<br>
@return&nbsp;the&nbsp;cycle&nbsp;length</tt></dd></dl>
 <dl><dt><a name="-main"><strong>main</strong></a>()</dt><dd><tt>runs&nbsp;the&nbsp;program</tt></dd></dl>
 <dl><dt><a name="-my_eval"><strong>my_eval</strong></a>()</dt><dd><tt>computes&nbsp;the&nbsp;max&nbsp;cycle&nbsp;length&nbsp;in&nbsp;the&nbsp;range&nbsp;[i,&nbsp;j]<br>
and&nbsp;stores&nbsp;the&nbsp;result&nbsp;in&nbsp;v</tt></dd></dl>
 <dl><dt><a name="-my_print"><strong>my_print</strong></a>(w)</dt><dd><tt>writes&nbsp;the&nbsp;values&nbsp;of&nbsp;i,&nbsp;j,&nbsp;and&nbsp;v</tt></dd></dl>
 <dl><dt><a name="-my_read"><strong>my_read</strong></a>(r)</dt><dd><tt>reads&nbsp;an&nbsp;int&nbsp;into&nbsp;i&nbsp;and&nbsp;j<br>
return&nbsp;true&nbsp;if&nbsp;that&nbsp;succeeds,&nbsp;false&nbsp;otherwise</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>cache</strong> = {}<br>
<strong>i</strong> = 0<br>
<strong>j</strong> = 0<br>
<strong>v</strong> = 0</td></tr></table>
</body></html>